<template>
	<view class="srys">
		<headertop str1="oridei" :back1="back1" title="私人医生"></headertop>
		<view class="addjianchaback">

		</view>
		<view class="" :style="{'margin-top':statusBarHeight+'px','width':'100%','height':barHeight+'px'}">
		</view>
		<view class="pagecenter">
			<view class="yishenguserinfo">
				<image :src="info.avatar?info.avatar:_static('/images/微信图片_20250709145843.png')" mode=""></image>
				<view class="nametext">
					<view class="t1">
						<span style="margin-right: 16rpx;">{{!info.doctor_name?'绑定私人医生':info.doctor_name}}</span>
						<span
							style="font-family: PingFang SC, PingFang SC;font-weight: 400;font-size: 26rpx;color: #4E5969;"
							v-if="info.title">{{info['title']}}
							| {{info['department_name']}}</span>
					</view>
					<view class="t2">
						{{!info.hospital_name?'还没有专属医生？我们为你守护健康':info.hospital_name}}
					</view>
				</view>
			</view>
			<view class="shanchantext" v-if="info.good_at">
				<view class="texts">
					<view class="line1">
						<view class="lable">
							擅长：
						</view>
						<view class="tts">
							{{info['good_at']||'无'}}
						</view>
					</view>
					<view class="line1">
						<view class="lable">
							简介：
						</view>
						<view class="tts">
							{{info['introduction']||'无'}}
						</view>
					</view>
					<!-- <view class="line1">
						<view class="lable">
							寄语：
						</view>
						<view class="tts">
							这是一个内容描述这是一个内容描述.
						</view>
					</view> -->
				</view>
			</view>

			<view class="shanchantext1" style="margin-bottom: 60rpx;" v-else>
				<view class="ljbd" @click="saoma">
					立即绑定
				</view>
			</view>

			<view class="titleline" v-if="info.avatar">
				<image :src="_static('/images/Group 11682@2x.png')" class="xbq" mode=""></image>
				<span>医院门诊排班</span>
			</view>
			<view class="table" v-if="info.avatar">
				<!-- 表头 -->
				<view class="table-row header">
					<view class="table-cell" style="background: #D7F1FF;"></view>
					<view class="table-cell" style="background: #D7F1FF;">一</view>
					<view class="table-cell" style="background: #D7F1FF;">二</view>
					<view class="table-cell" style="background: #D7F1FF;">三</view>
					<view class="table-cell" style="background: #D7F1FF;">四</view>
					<view class="table-cell" style="background: #D7F1FF;">五</view>
					<view class="table-cell" style="background: #D7F1FF;">六</view>
					<view class="table-cell" style="background: #D7F1FF;">日</view>
				</view>

				<!-- 表格内容 -->
				<view class="table-row">
					<view class="table-cell">上午</view>
					<view class="table-cell" v-for="(item,index) in  workSchedulingarr['morning']||7" :key="index">
						<image :src="_static('/images/Group 11730@2x.png')" class="duihaoicon" mode=""
							v-if="item==1&&workSchedulingarr['morning']"></image>
					</view>

				</view>
				<view class="table-row">
					<view class="table-cell">下午</view>
					<view class="table-cell" v-for="(item,index) in  workSchedulingarr['afternoon']||7" :key="index">
						<image :src="_static('/images/Group 11730@2x.png')" class="duihaoicon" mode=""
							v-if="item==1&&workSchedulingarr['afternoon']"></image>
					</view>

				</view>
				<view class="table-row">
					<view class="table-cell">晚上</view>
					<view class="table-cell" v-for="(item,index) in  workSchedulingarr['evening']||7" :key="index">
						<image :src="_static('/images/Group 11730@2x.png')" class="duihaoicon" mode=""
							v-if="item==1&&workSchedulingarr['evening']"></image>
					</view>
				</view>
			</view>
			<image :src="_static('/images/Group 11706@2x.png')" @click="wenjuan" v-if="info.avatar" class="image1"
				mode="">
			</image>
		</view>
	</view>

</template>

<script setup>
	import {
		_static
	} from '@/ulm/utils/url.js'
	import ulm, {
		$api
	} from '@/ulm';
	import headertop from '@/components/header.vue'
	import {
		ref,
		reactive,
		onMounted
	} from 'vue'
	import {
		onPageScroll,
		onLoad,
		onShow,
		onReachBottom
	} from "@dcloudio/uni-app";
	const statusBarHeight = ref('')
	const barHeight = ref('')
	const info = ref({})
	const back1 = ref('')
	const workSchedulingarr = ref({})
	const tableData = ref([{
		name: '张三',
		age: 25,
		job: '工程师'
	}])
	onLoad(() => {
		init()
	})
	async function init() {
		const res = await $api.doctorInfo()
		if (res.code == 1) {
			info.value = res.data
			console.log(info.value, 'infoinfoinfoinfo');
		}
		const res1 = await $api.workScheduling()
		if (res1.code == 1) {
			workSchedulingarr.value = res1.data.work_scheduling
			console.log(res1.data, 'infoinfoinfoinfo');
		}
	}

	function wenjuan() {
		uni.navigateTo({
			url: '/sub_my/my/newwenjuan'
		})
	}

	function saoma() {
		uni.scanCode({
			success: function(res) {
				console.log(res, 'resresresresresres');
				console.log(decodeURIComponent(res.path).replace('?', '&'),
					'decodeURIComponentdecodeURIComponentdecodeURIComponent');
				const str = decodeURIComponent(res.path).replace('?', '&')
				let strArr = str.split('&')
				strArr = strArr.filter(item => item)
				const result = {}
				console.log(strArr, 'strArr-------------');
				strArr.filter(item => {
					const key = item.split('=')
					result[key[0]] = key[1]
				})

				bindDoctorinit(result['scene'])
			}
		});

	}
	async function bindDoctorinit(id) {
		const res = await $api.bindDoctor({
			'doctor_id': id
		})
		if (res.code == 1) {
			init()
			setTimeout(() => {
				uni.showToast({
					title: '绑定成功',
					icon: 'none'
				})
			}, 500)
		} else {
			uni.showToast({
				title: res.msg,
				icon: 'none'
			})
		}
	}
	onPageScroll((e) => {
		if (e.scrollTop > 100) {
			back1.value = '#81D6FF'
		} else {
			back1.value = ''
		}
	})
	onMounted(() => {
		statusBarHeight.value = uni.getSystemInfoSync().statusBarHeight
		const {
			top,
			height
		} = wx.getMenuButtonBoundingClientRect();
		barHeight.value = height ? height + (top - statusBarHeight.value) * 2 : 38;
	})
</script>

<style lang="scss">
	.image1 {
		width: 100%;
		height: 176rpx;
		margin-top: 32rpx;
	}

	.table {
		width: 100%;
		border: 1px solid #F2F3F5;
		margin-top: 34rpx;
		overflow: hidden;
		border-radius: 20rpx;
		box-shadow: 0rpx 4rpx 19rpx 0rpx #D7F1FF;
		box-sizing: border-box;
		border-top: 1rpx solid #D7F1FF;
	}

	.table-row {
		display: flex;
	}

	.header {
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 30rpx;
		color: #1D2129;
		box-shadow: 0 4rpx 19rpx #D7F1FF;
	}

	.table-cell {
		width: 86rpx;
		text-align: center;
		flex: 1;
		border-bottom: 1px solid #e0e0e0;
		border-right: 1px solid #e0e0e0;
		text-align: center;
		font-size: 26rpx;
		height: 88rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		line-height: 88rpx;
		white-space: nowrap;

		.duihaoicon {
			width: 45rpx;
			height: 45rpx;
		}
	}

	.table-cell:last-child {
		border-right: none;
	}

	.table-row:last-child .table-cell {
		border-bottom: none;
	}

	.srys {
		width: 100%;
		overflow: hidden;
		position: relative;

		.addjianchaback {
			width: 100%;
			height: 554rpx;
			background: linear-gradient(180deg, #CAEEFF 71%, rgba(240, 250, 255, 0) 100%);
			border-radius: 0rpx 0rpx 0rpx 0rpx;
			position: absolute;
			z-index: -1;
		}

		.pagecenter {
			width: 686rpx;
			margin: auto;
			margin-top: 40rpx;
			overflow: hidden;

			.titleline {
				width: 100%;
				display: flex;
				align-items: center;
				font-family: PingFang SC, PingFang SC;
				font-weight: bold;
				font-size: 32rpx;
				color: #1D2129;
				margin-top: 40rpx;

				.xbq {
					width: 34rpx;
					height: 20rpx;
					margin-right: 14rpx;
				}

			}

			.tablebox {
				width: 100%;
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				overflow: hidden;
			}

			.shanchantext1 {
				width: 686rpx;
				height: 180rpx;
				background: #FFFFFF;
				box-shadow: 0rpx 4rpx 19rpx 0rpx rgba(0, 0, 0, 0.09);
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				margin-top: 38rpx;

				.ljbd {
					width: 324rpx;
					height: 82rpx;
					background: #2AB4F5;
					border-radius: 12rpx 12rpx 12rpx 12rpx;
					text-align: center;
					line-height: 82rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 32rpx;
					color: #FFFFFF;
				}
			}

			.shanchantext {
				background: #FFFFFF;
				box-shadow: 0rpx 4rpx 19rpx 0rpx rgba(0, 0, 0, 0.09);
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				overflow: hidden;
				width: 100%;
				margin-top: 28rpx;
				overflow: hidden;

				.texts {
					width: 612rpx;
					margin-left: 28rpx;
					overflow: hidden;
					margin-top: 28rpx;

					.line1 {
						width: 100%;
						display: flex;
						justify-content: space-between;
						margin-bottom: 32rpx;

						.lable {
							font-family: PingFang SC, PingFang SC;
							font-weight: 500;
							font-size: 28rpx;
							color: #1D2129;
						}

						.tts {
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							font-size: 26rpx;
							color: #4E5969;
							width: 526rpx;
							overflow: hidden;
						}
					}
				}
			}

			.yishenguserinfo {
				width: 100%;
				display: flex;
				align-items: center;

				image {
					width: 108rpx;
					height: 108rpx;
					border-radius: 16rpx 16rpx 16rpx 16rpx;
				}

				.nametext {
					margin-left: 20rpx;

					.t1 {
						font-family: PingFang SC, PingFang SC;
						font-weight: 500;
						font-size: 34rpx;
						color: #1D2129;
					}

					.t2 {
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 26rpx;
						color: #1D2129;
						margin-top: 16rpx;
					}
				}
			}
		}
	}
</style>